package com.example.user.feign;

import com.example.common.response.Result;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

@Component
public class ProductFeignClientFallbackFactory implements FallbackFactory<ProductFeignClient> {
    
    private static final Logger log = LoggerFactory.getLogger(ProductFeignClientFallbackFactory.class);
    
    @Override
    public ProductFeignClient create(Throwable cause) {
        log.error("商品服务调用失败", cause);
        return new ProductFeignClient() {
            @Override
            public Result<Object> getProduct(Long id) {
                return Result.error("商品服务调用失败，请稍后重试");
            }
        };
    }
} 